﻿<%@ WebHandler Language="C#" Class="search" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Text;
using System.Configuration;
public class search : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string pretext = context.Request.QueryString["q"];
        using (SqlCommand cmd = DataAccess.Connection.CreateCommand()) ;
        cmd.CommandText = " select distinct pname from Product where" + " pname like @tensp + '%'";
        cmd.Parameters.AddWithValue("@tensp", pretext);
        //cmd.Parameters.Add("@tensp", SqlDbType.NVarChar).Value = TextBox1.Text;
        StringBuilder sb = new StringBuilder();
        using (SqlDataReader dr = cmd.ExecuteReader()) ;

        while (dr.Read())
        {
            sb.Append(dr["pname"])
                .Append(Environment.NewLine);
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}